goog.provide('lfpug.events.ArrayCollectionEvent');
goog.provide('lfpug.events.ArrayCollectionEvent.EventType');
goog.require('goog.events');
goog.require('lfpug.events.ModelChangeEvent');
goog.require('lfpug.model.BaseModel');



/**
 * @constructor
 * @param {!string} type The event type.
 * @param {lfpug.model.BaseModel|lfpug.model.ArrayCollection=} opt_data
 *    The associated model should be the same as the events target.
 * @param {Array.<goog.events.Event>=} opt_chain The bubble chain of this event.
 * @param {Object=} opt_target the optional event target. See parent class docs.
 * @extends {lfpug.events.ModelChangeEvent}
 */
lfpug.events.ArrayCollectionEvent = function(type, opt_data, opt_chain,
    opt_target) {
  goog.base(this, type,/** @type {!lfpug.model.BaseModel}*/ (opt_data),
      opt_chain, opt_target);


};
goog.inherits(
    lfpug.events.ArrayCollectionEvent,
    lfpug.events.ModelChangeEvent
);


/**
 * @param {number} i The old items index, this is only set with MOVE events.
 */
lfpug.events.ArrayCollectionEvent.prototype.setItemIndex = function(i) {
  this.itemIndex = i;
};


/**
 * @return {number} The old items index, this is only set with MOVE events.
 */
lfpug.events.ArrayCollectionEvent.prototype.getItemIndex = function() {
  return this.itemIndex;
};


/**
 * @param {number} i The old items index, this is only set with MOVE events.
 */
lfpug.events.ArrayCollectionEvent.prototype.setOldItemIndex = function(i) {
  this.oldItemIndex = i;
};


/**
 * @return {number} The old items index, this is only set with MOVE events.
 */
lfpug.events.ArrayCollectionEvent.prototype.getOldItemIndex = function() {
  return this.oldItemIndex;
};


/**
 * @param {lfpug.model.BaseModel} model The old item you wish to persist
 * on this event.
 */
lfpug.events.ArrayCollectionEvent.prototype.setOldItem =
    function(model) {
  if (goog.isDefAndNotNull(model)) {
    this.oldItem = model;
  }
};


/**
 * @return {?lfpug.model.BaseModel} The old item stored by this event. For
 * when you use arraycollection.setItemAt which replaces the index there.
 */
lfpug.events.ArrayCollectionEvent.prototype.getOldItem = function() {
  return this.oldItem;
};


/**
 * Specifies the event types dispatched by ArrayCollection
 * @enum {string}
 */
lfpug.events.ArrayCollectionEvent.EventType = {
  ADD: goog.events.getUniqueId('add'),
  REMOVE: goog.events.getUniqueId('remove'),
  REMOVE_ALL: goog.events.getUniqueId('remove_all'),
  CHANGE: goog.events.getUniqueId('change'),
  SET: goog.events.getUniqueId('set'),
  SORT: goog.events.getUniqueId('sort'),
  MOVE: goog.events.getUniqueId('move')
};
